package com.neusoft.elmboot.po;

import com.neusoft.elmboot.po.VirtualWallet;

import java.math.BigDecimal;

public class VirtualWalletDomain extends VirtualWallet{
	
	
	
	public VirtualWalletDomain(VirtualWallet wallet){
		this.id = wallet.id;
        this.balance = wallet.balance;
        this.createTime = wallet.createTime;
    }
	
	public void debit(BigDecimal amount) throws Exception{
		
		if(this.balance.compareTo(amount)<0) {
			throw new Exception();
		}
		this.balance = this.balance.subtract(amount);
	}

	public void credit(BigDecimal amount) throws Exception{
		
		if(amount.compareTo(BigDecimal.ZERO) < 0){
			throw new Exception();
		}
		this.balance = this.balance.add(amount);
	}
}

